String compare?

Hi all,

i have a problem. I want to compare 2 strings with this code

if(matches(str, str2))
{
    //Do something 
        print str "|" str2 "\n" 
}

and this is what i get

1. Test|Test
2. Test|Test.admin
3. Test.admin|Test.admin

why is 2. true? I only want that is 1. and 3. true....


meinhana - Fri Jul 31 07:01:11 EDT 2015

Re: String compare?
Wolfgang Uhr - Fri Jul 31 08:14:57 EDT 2015

Hi

The first parameter of matches is a regular expression string. If this string has the value "Test", then "Test.admin" hits this regexp and so the result is true.

Best regards

Wolfgang

Re: String compare?
DoorsXLAustralia - Sun Aug 02 08:25:55 EDT 2015

why is 2. true? I only want that is 1. and 3. true....

 

For equality just use the "==" operator

if(str == str2)

Re: String compare?
meinhana - Tue Aug 04 04:10:39 EDT 2015

DoorsXLAustralia - Sun Aug 02 08:25:55 EDT 2015

why is 2. true? I only want that is 1. and 3. true....

 

For equality just use the "==" operator

if(str == str2)

Thank you!

Re: String compare?
meinhana - Tue Aug 25 03:40:52 EDT 2015

How can I check the last 4 characters ?
I want to check if there are the same in string 1

Like

string1 = ".txt"
string2 = "C:\xxx.csv"

if same => true
if not same => false

Re: String compare?
Mike.Scharnow - Tue Aug 25 05:26:26 EDT 2015

meinhana - Tue Aug 25 03:40:52 EDT 2015

How can I check the last 4 characters ?
I want to check if there are the same in string 1

Like

string1 = ".txt"
string2 = "C:\xxx.csv"

if same => true
if not same => false

open DXL manual, search for "string extract", you will see chapter "Substring extraction from string".

index notation and length() will help....

print s[ (length s) -4 : ]

 

Re: String compare?
meinhana - Tue Aug 25 05:32:05 EDT 2015

Mike.Scharnow - Tue Aug 25 05:26:26 EDT 2015

open DXL manual, search for "string extract", you will see chapter "Substring extraction from string".

index notation and length() will help....

print s[ (length s) -4 : ]

 

Thanks, exactly what i need :)